import * as actionType from "./actionType"

// 默认初始数据
const initState = {
  id: 1,
  data: [],
  count: 0,
  current: 1,
  pageSize: 10,
  obj: {
    id: 1,
    name: '王娇娇',
    applied_amount: 500000,
    payback_rest: 2000,
    phone: "12345678901",
    state: 1,
    total: "10",
  }
}


// 调用方法判定执行
function reducer(state = initState, action) {
  switch (action.type) {
    case actionType.GET_Id:
      return {
        ...state,
        id: action.id,
      }
    case actionType.GET_USER:
      return {
        ...state,
        obj: { ...action.obj },
      }
    case actionType.SET_PAGE:
      return {
        ...state,
        pageSize:action.pageSize,
        current:action.current
      }

    case actionType.GET_ManagementList:
      return {
        ...state,
        data: [...action.list],
        count: action.count,
      }
    default:
      return state
  }
}

export default reducer